VERSION=0.33
PREFIX=/hardmnt/tharpe0/sra/serra/Software/Developing/JaCoLiB/distr/${VERSION}
D=`pwd`

mkdir -p ${PREFIX}
mkdir -p ${PREFIX}/jacolib/src
mkdir -p ${PREFIX}/jacolib/libs
mkdir -p ${PREFIX}/jacolib/cl-packages
mkdir -p ${PREFIX}/jacolib/cl-packages/asdf-registry
mkdir -p ${PREFIX}/distrs

cd jacolib-java
mvn clean
cd ../jacolib-lisp/jacolib
./scripts/clean-lisp-comp.sh
cd ${D}

cp -r jacolib-java ${PREFIX}/jacolib/src
cp -r jacolib-lisp ${PREFIX}/jacolib/src
find ${PREFIX}/jacolib/src/jacolib-lisp -name ".svn" | xargs -t -i rm -rf {}

cd jacolib-java
mvn install
cp /hardmnt/tharpe0/sra/serra/Work/ONE/Software/.m2/repository/it/gashale/jacolib/${VERSION}/jacolib-${VERSION}.jar ${PREFIX}/jacolib/libs
cp /hardmnt/tharpe0/sra/serra/Work/ONE/Software/.m2/repository/rhino/js/1.7R1/js-1.7R1.jar ${PREFIX}/jacolib/libs
cp ./modules/jacolib/src/main/java/jacolib.properties ${PREFIX}/jacolib/libs
mvn clean
cd ${D}

cd ${PREFIX}/jacolib/src/jacolib-lisp
tar zcf jacolib-cl-${VERSION}.tgz jacolib
mv jacolib-cl-${VERSION}.tgz ${PREFIX}/jacolib/libs
cd ${D}

cd ${PREFIX}/jacolib/cl-packages
tar zxf ../libs/jacolib-cl-${VERSION}.tgz
ln -s ${PREFIX}/jacolib/cl-packages/jacolib/jacolib.asd ${PREFIX}/jacolib/cl-packages/asdf-registry/
tar zxf ${D}/jacolib-lisp/cl-packages/cl-json_0.3.1.tar.gz
ln -s ${PREFIX}/jacolib/cl-packages/cl-json_0.3.1/cl-json.asd ${PREFIX}/jacolib/cl-packages/asdf-registry/
tar zxf ${D}/jacolib-lisp/cl-packages/md5-1.8.5.tar.gz
ln -s ${PREFIX}/jacolib/cl-packages/md5-1.8.5/md5.asd ${PREFIX}/jacolib/cl-packages/asdf-registry/
tar zxf ${D}/jacolib-lisp/cl-packages/parenscript-latest.tar.gz
ln -s ${PREFIX}/jacolib/cl-packages/parenscript-20071104/parenscript.asd ${PREFIX}/jacolib/cl-packages/asdf-registry/
tar zxf ${D}/jacolib-lisp/cl-packages/portable-threads_latest.tar.gz
ln -s ${PREFIX}/jacolib/cl-packages/portable-threads/portable-threads.asd ${PREFIX}/jacolib/cl-packages/asdf-registry/
tar zxf ${D}/jacolib-lisp/cl-packages/usocket-0.3.7.tar.gz
ln -s ${PREFIX}/jacolib/cl-packages/usocket-0.3.7/usocket.asd ${PREFIX}/jacolib/cl-packages/asdf-registry/
tar zxf ${D}/jacolib-lisp/cl-packages/split-sequence.tar.gz
ln -s ${PREFIX}/jacolib/cl-packages/split-sequence/split-sequence.asd ${PREFIX}/jacolib/cl-packages/asdf-registry/


cd ${PREFIX}
cp ./jacolib/libs/jacolib-${VERSION}.jar ./distrs
cp ./jacolib/libs/jacolib.properties ./distrs/jacolib-${VERSION}.properties.sample
cp ./jacolib/libs/jacolib-cl-${VERSION}.tgz ./distrs
tar zcf ./distrs/jacolib-src-${VERSION}.tgz ./jacolib/src
tar zcf ./distrs/jacolib-full-${VERSION}.tgz ./jacolib
cd ${D}

